﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="H2.NET.Web.Management.Permission.Index" %>

<%@ Register src="../../UserControls/Toolbar.ascx" tagname="Toolbar" tagprefix="uc1" %>
<% var divId = System.Guid.NewGuid().ToString().Replace("-", ""); %>
<form id="pagerForm" onsubmit="return navTabSearch(this);" action="<%= Request.RawUrl %>"
method="post">
</form>
<%--<div class="pageContent">
    <div class="panelBar" style="border-top: 0;">
        <ul class="toolBar">
            <uc1:toolbar ID="Toolbar1" runat="server" />
        </ul>
    </div>
</div>--%>
<div id="<%= divId %>" style="border:0;">
</div>
<input id="selectedId" type="hidden" />
<script type="text/javascript">

    $(function () {

        $("#<%= divId %>").ligerGrid({
            columns: [
                    { display: 'ID', name: 'ID', hide: 1 },
					{ display: '<b>权限名称</b>', name: 'Name', align: 'left', width: '200' },
					{ display: '<b>权限编码</b>', name: 'RelCode', align: 'left', width: '120' },
					{ display: '<b>地址</b>', name: 'Url', align: 'left', width: '340' },
                    { display: '<b>级别</b>', name: 'Layer', align: 'center', width: '80' }
				], height: ($(window).height() - 120),
            allowHideColumn: false, rownumbers: true, colDraggable: true, rowDraggable: true,
            checkbox: false, alternatingRow: false, usePager: false, allowUnSelectRow: true, allowUnSelectRow: true,

            // 设置数据源
            dataAction: 'server', url: "/Management/Permission/Handler.ashx?action=GetData", tree: { columnName: 'Name' },

            // 单击选择行时触发
            onSelectRow: function (rowdata, rowindex, rowDomElement) {
                $("#selectedId", navTab.getCurrentPanel()).val(rowdata.ID);
            },

            // 再次单击选择时出发
            onUnSelectRow: function (data, rowindex, rowobj) {
                $("#selectedId", navTab.getCurrentPanel()).val("");
            }
        });
    });
    function PermissionTJ(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        $.pdialog.open(url + "?id=" + id, rel, title, { width: 500, height: 400, mask: true });
        return false;
    }
    function PermissionCreate(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        $.pdialog.open(url + "?id=" + id, rel, title, { width: 1000, height: 500, mask: true });
        return false;
    }
    function PermissionEdit(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        $.pdialog.open(url + "?id=" + id, rel, title, { width: 500, height: 400, mask: true });
        return false;
    }
    function PermissionDelete(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        alertMsg.confirm(title, {
            okCall: function () {
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: { id: id, title: title },
                    dataType: "json",
                    cache: false,
                    success: function (json) {
                        DWZ.ajaxDone(json);
                        navTabSearch($("#pagerForm", navTab.getCurrentPanel()));
                    },
                    error: DWZ.ajaxError
                });

            }
        });
        return false;
    }
</script>

